
Ext.define('Writer.Person', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int'
    }, 'nombreRol', 'descripcion','fecha','tipoRol']
});

//Ext.Loader.setConfig({enabled: true});
//Ext.Loader.setPath('Ext.ux', 'static/ux');

Ext.define('administracion.RolesGrid', {  extend: 'Ext.grid.Panel',  alias: 'widget.writergrid',
    requires: [ 
				'Ext.form.field.Text',
				//'Ext.ux.grid.FiltersFeature',
				'Ext.toolbar.TextItem' ],

    initComponent: function(){
        
        //var filters = {		ftype: 'filters',	local: true,	};

        Ext.apply(this, {
            iconCls: 'icon-grid', 
            //frame: true, 
            //features: [filters],
            dockedItems: [{ 
						weight: 1, 
						xtype: 'toolbar',  
						dock: 'bottom',  
						items: ['->',{   
								iconCls: 'icon-refresh',  
								text: '<b>Actualizar</b>',
								tooltip:'Actualizar la lista',  
								scope: this,  
								handler: this.onRefresh	
							}]
			}],
            columns: [		{		
							text: 'Id', 
							hidden: true,
							width: 40,  
							dataIndex: 'id',  
							//filter: true,  
							},
						{		
							header: '<b>Nombre Rol</b>',   
							width: 150,     
							dataIndex: 'nombreRol',     
							//filter: true,   
							},
						{		
							header: '<b>Descripcion</b>',   
							flex:1,   
							//filter: true,   
							dataIndex: 'descripcion',      
							},
						{		
							header: '<b>Tipo Plantilla</b>', 
							width: 130,   
							//filter: true,   
							dataIndex: 'tipoRol',      
							},
						{		
							header: '<b>Fecha Creacion</b>',
							width: 120,  
							//filter: true,   
							dataIndex: 'fecha',
						}]
        });
        this.callParent();
        this.getSelectionModel().on('selectionchange', this.onSelectChange, this);
    },
    
    onListar: function(){
		this.getSelectionModel().clearSelections();
		this.store.load();
    },    
    
    onRefresh: function(){
		this.getSelectionModel().clearSelections();
		this.store.load();
	},
});
